package replicant1;

import java.util.Comparator;

public class Result {

	public static Comparator<Result> idComparator = new Comparator<Result>() {

		@Override
		public int compare(Result c1, Result c2) {

			return (int) (c2.priority - c1.priority);

		}

	};

	public int priority;

	public int count;

	public String result1;

	public String result2;

	public String result3="re3";

	public String correctResult() {

		if (result1.equals(result2)) {

			return result2;

		}

		if (result1.equals(result3)) {

			return result3;

		}

		if (result2.equals(result3)) {

			return result2;

		}

		return result1;

	}

	/*
	 * 
	 * 0 for nothing
	 * 
	 * 1 for leader/replicant1
	 * 
	 * 2 for replicant2
	 * 
	 * 3 for replicant3
	 */

	public String getErrorHost() {

		if (!result1.equals(this.correctResult())) {

			return "1";

		}

		if (!result2.equals(this.correctResult()))  {

			return "2";

		}

		if (!result3.equals(this.correctResult()))  {

			return "3";

		}

		return "0";

	}

	public Result() {

		count = 0;

	}

}